<?php

/*
 * Created by generator
 *
 */

/**
 * Recupere la liste des enregistrements
 * @param object $db database object
 * @return array of data
 */
if (!function_exists('getAllSituationsFromDB')) {
	function getAllSituationsFromDB($db) {
		$sql = "SELECT sitidsit, sitlbnom from gyasit ";
		$query = $db->query($sql);

		// recuperer les enregistrements
		$records = array();
		foreach ($query->result_array() as $row) {
			$records[] = $row;
		}
		return $records;
	}
}


/**
 * Insere un nouvel enregistrement
 * @param object $db database object
 * @param string ...
 * @return number identifiant
 */
if (!function_exists('insertNewSituation')) {
	function insertNewSituation($db, $sitlbnom) {
		$data=array( 'sitlbnom'=>$sitlbnom );
		$db->insert('gyasit',$data);
		return $db->insert_id();
	}
}

/**
 * Mise a jour d'un enregistrement
 */
if (!function_exists('updateSituation')) {
	function updateSituation($db, $sitidsit, $sitlbnom) {
		$sql = "update gyasit set sitlbnom = ? where sitidsit=?";
		$query = $db->query($sql, array($sitlbnom, (int)$sitidsit ));
	}
}


/**
 * Suppression d'un enregistrement
 */
if (!function_exists('deleteSituation')) {
	function deleteSituation($db, $sitidsit) {
		$sql = "delete from gyasit where sitidsit=?";
		$query = $db->query($sql, array((int)$sitidsit));
	}
}


/**
 * Recupere les informations d'un enregistrement
 * @param object $db database object
 * @param int id de l'enregistrement
 * @return array
 */
if (!function_exists('getSituationRow')) {
	function getSituationRow($db, $sitidsit) {
		$sql = "select sitidsit, sitlbnom from gyasit " .
		"where sitidsit=?";
		$query = $db->query($sql, array((int)$sitidsit));
		if ($query->num_rows() == 0) {
			return null;
		}
		return $query->row_array();
	}
}

	/***************************************************************************
	 * USER DEFINED FUNCTIONS
	 ***************************************************************************/


?>
